/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ms.jasim.model.event.provider;

import java.util.ArrayList;
import java.util.Collection;

import ms.jasim.model.event.util.EventAdapterFactory;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class EventItemProviderAdapterFactory extends EventAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EventItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.EventModel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EventModelItemProvider eventModelItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.EventModel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEventModelAdapter() {
		if (eventModelItemProvider == null) {
			eventModelItemProvider = new EventModelItemProvider(this);
		}

		return eventModelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.EventSet} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EventSetItemProvider eventSetItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.EventSet}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEventSetAdapter() {
		if (eventSetItemProvider == null) {
			eventSetItemProvider = new EventSetItemProvider(this);
		}

		return eventSetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.Event} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EventItemProvider eventItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.Event}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEventAdapter() {
		if (eventItemProvider == null) {
			eventItemProvider = new EventItemProvider(this);
		}

		return eventItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.AbsoluteTime} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AbsoluteTimeItemProvider absoluteTimeItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.AbsoluteTime}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAbsoluteTimeAdapter() {
		if (absoluteTimeItemProvider == null) {
			absoluteTimeItemProvider = new AbsoluteTimeItemProvider(this);
		}

		return absoluteTimeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.EventRelativeTime} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EventRelativeTimeItemProvider eventRelativeTimeItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.EventRelativeTime}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEventRelativeTimeAdapter() {
		if (eventRelativeTimeItemProvider == null) {
			eventRelativeTimeItemProvider = new EventRelativeTimeItemProvider(this);
		}

		return eventRelativeTimeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ActionRelativeTime} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionRelativeTimeItemProvider actionRelativeTimeItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ActionRelativeTime}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionRelativeTimeAdapter() {
		if (actionRelativeTimeItemProvider == null) {
			actionRelativeTimeItemProvider = new ActionRelativeTimeItemProvider(this);
		}

		return actionRelativeTimeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.SolutionInconsistent} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SolutionInconsistentItemProvider solutionInconsistentItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.SolutionInconsistent}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSolutionInconsistentAdapter() {
		if (solutionInconsistentItemProvider == null) {
			solutionInconsistentItemProvider = new SolutionInconsistentItemProvider(this);
		}

		return solutionInconsistentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.CompositePrecondition} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CompositePreconditionItemProvider compositePreconditionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.CompositePrecondition}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCompositePreconditionAdapter() {
		if (compositePreconditionItemProvider == null) {
			compositePreconditionItemProvider = new CompositePreconditionItemProvider(this);
		}

		return compositePreconditionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ReactionList} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReactionListItemProvider reactionListItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ReactionList}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createReactionListAdapter() {
		if (reactionListItemProvider == null) {
			reactionListItemProvider = new ReactionListItemProvider(this);
		}

		return reactionListItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ModifyModelReaction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModifyModelReactionItemProvider modifyModelReactionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ModifyModelReaction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createModifyModelReactionAdapter() {
		if (modifyModelReactionItemProvider == null) {
			modifyModelReactionItemProvider = new ModifyModelReactionItemProvider(this);
		}

		return modifyModelReactionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ModifyObjectReaction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModifyObjectReactionItemProvider modifyObjectReactionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ModifyObjectReaction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createModifyObjectReactionAdapter() {
		if (modifyObjectReactionItemProvider == null) {
			modifyObjectReactionItemProvider = new ModifyObjectReactionItemProvider(this);
		}

		return modifyObjectReactionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ReplanReaction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReplanReactionItemProvider replanReactionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ReplanReaction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createReplanReactionAdapter() {
		if (replanReactionItemProvider == null) {
			replanReactionItemProvider = new ReplanReactionItemProvider(this);
		}

		return replanReactionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ForAllReaction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ForAllReactionItemProvider forAllReactionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ForAllReaction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createForAllReactionAdapter() {
		if (forAllReactionItemProvider == null) {
			forAllReactionItemProvider = new ForAllReactionItemProvider(this);
		}

		return forAllReactionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.ForAllGoalDomain} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ForAllGoalDomainItemProvider forAllGoalDomainItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.ForAllGoalDomain}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createForAllGoalDomainAdapter() {
		if (forAllGoalDomainItemProvider == null) {
			forAllGoalDomainItemProvider = new ForAllGoalDomainItemProvider(this);
		}

		return forAllGoalDomainItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link ms.jasim.model.event.CustomReaction} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CustomReactionItemProvider customReactionItemProvider;

	/**
	 * This creates an adapter for a {@link ms.jasim.model.event.CustomReaction}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCustomReactionAdapter() {
		if (customReactionItemProvider == null) {
			customReactionItemProvider = new CustomReactionItemProvider(this);
		}

		return customReactionItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (eventModelItemProvider != null) eventModelItemProvider.dispose();
		if (eventSetItemProvider != null) eventSetItemProvider.dispose();
		if (eventItemProvider != null) eventItemProvider.dispose();
		if (absoluteTimeItemProvider != null) absoluteTimeItemProvider.dispose();
		if (eventRelativeTimeItemProvider != null) eventRelativeTimeItemProvider.dispose();
		if (actionRelativeTimeItemProvider != null) actionRelativeTimeItemProvider.dispose();
		if (solutionInconsistentItemProvider != null) solutionInconsistentItemProvider.dispose();
		if (compositePreconditionItemProvider != null) compositePreconditionItemProvider.dispose();
		if (reactionListItemProvider != null) reactionListItemProvider.dispose();
		if (modifyModelReactionItemProvider != null) modifyModelReactionItemProvider.dispose();
		if (modifyObjectReactionItemProvider != null) modifyObjectReactionItemProvider.dispose();
		if (replanReactionItemProvider != null) replanReactionItemProvider.dispose();
		if (forAllReactionItemProvider != null) forAllReactionItemProvider.dispose();
		if (forAllGoalDomainItemProvider != null) forAllGoalDomainItemProvider.dispose();
		if (customReactionItemProvider != null) customReactionItemProvider.dispose();
	}

}
